package com.qzsoft.system.modules.sysmenu.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.qzsoft.jeemis.common.utils.Result;
import com.qzsoft.system.modules.sysmenu.service.SysMenuService;
import com.qzsoft.zhjd.common.utils.ResultUtils;

/**
 * @ClassName SysMenuController
 * @Description 系统菜单控制器
 * @author linhuawei
 * @since 2022-05-17
 */
@RestController
@RequestMapping("/api/sysMenu")
public class SysMenuController {

    @Autowired
    private SysMenuService sysMenuService;

    @GetMapping("/getPathName")
    public Result<List<String>> getMenuPath(@RequestParam(required = false) Map<String, Object> map) {
        return ResultUtils.ok(sysMenuService.getPathName(map));
    }

    @PostMapping("/getPathName")
    public Result<List<String>> getMenuPathByPost(@RequestBody Map<String, Object> map) {
        if (null == map.get("path")) {
            return ResultUtils.ok(new ArrayList<>());
        }
        return ResultUtils.ok(sysMenuService.getPathName(map));
    }

}
